package com.jsj.controller;

import com.jsj.pojo.BorrowHistory;
import com.jsj.pojo.DeviceHistory;
import com.jsj.pojo.RepairHistory;
import com.jsj.service.HistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class HistoryController {

    @Autowired
    HistoryService historyService;
//三个controller,三个关键字搜索
    @RequestMapping("/queryDeviceHistory")
    @ResponseBody
    public List<DeviceHistory> queryDeviceHistory(String deviceName){
        List<DeviceHistory> deviceHistoryList = historyService.queryDeviceHistory(deviceName);
        System.out.println("-------"+deviceHistoryList);
        return deviceHistoryList;
    }

    @RequestMapping("/queryBorrowHistory")
    @ResponseBody
    public List<BorrowHistory> queryBorrowHistory(String deviceName){
        List<BorrowHistory> borrowHistoryList = historyService.queryBorrowHistory(deviceName);
        System.out.println("-------"+borrowHistoryList);
        return borrowHistoryList;
    }

    @RequestMapping("/queryRepairHistory")
    @ResponseBody
    public List<RepairHistory> queryRepairHistory(String deviceName){
        List<RepairHistory> repairHistoryList = historyService.queryRepairHistory(deviceName);
        System.out.println("-------"+repairHistoryList);
        return repairHistoryList;
    }

    //三个删除记录
    @RequestMapping("/delDeviceHistoryById")
    @ResponseBody
    public Boolean delDeviceHistoryById(int historyId){
        Boolean flag = historyService.delDeviceHistoryById(historyId);
        return flag;
    }
    @RequestMapping("/delBorrowHistoryById")
    @ResponseBody
    public Boolean delBorrowHistoryById(int historyId){
        Boolean flag = historyService.delBorrowHistoryById(historyId);
        return flag;
    }
    @RequestMapping("/delRepairHistoryById")
    @ResponseBody
    public Boolean delRepairHistoryById(int historyId){
        Boolean flag = historyService.delRepairHistoryById(historyId);
        return flag;
    }
//清空所有历史记录
    @RequestMapping("/delAllHistory")
    @ResponseBody
    public Boolean delAllHistory(){
        Boolean flag = historyService.delAllHistory();
        return flag;
    }

    //清空devicehistory历史记录
    @RequestMapping("/delDeviceHistory")
    @ResponseBody
    public Boolean delDeviceHistory(){
        Boolean flag = historyService.delDeviceHistory();
        return flag;
    }

    //清空borrowhistory历史记录
    @RequestMapping("/delBorrowHistory")
    @ResponseBody
    public Boolean delBorrowHistory(){
        Boolean flag = historyService.delBorrowHistory();
        return flag;
    }
    //清空borrowhistory历史记录
    @RequestMapping("/delRepairHistory")
    @ResponseBody
    public Boolean delRepairHistory(){
        Boolean flag = historyService.delRepairHistory();
        return flag;
    }



}
